const express = require('express')
const app = express()
const cors = require('cors')
const path = require('path')
app.use(cors())
app.use(express.urlencoded({ extended: false }))
app.use(express.json())
// const history = require("connect-history-api-fallback")
// app.use(history())

// 为了访问 该服务器下的 index.html
// const staticRoot = path.resolve(__dirname, "./public");

// app.use(express.static(staticRoot))

const userRouter = require('./router/user.js')
const sportsRouter = require('./router/sports')
const itemRouter = require('./router/item.js')
const scoreRouter = require('./router/score.js')


/**
 * test
 */
app.get('/uml-api/ping',async (req,res,next) => {
  res.send('ping pass')
})

app.use('/uml-api', userRouter)
app.use('/uml-api', sportsRouter)
app.use('/uml-api', itemRouter)
app.use('/uml-api', scoreRouter)

app.listen(8080, function () {
  console.log('api server running at http://127.0.0.1:8080')
})